/*
 * AddressTests.cpp
 *
 *  Created on: 31 ��� 2010
 *      Author: Sartios
 */

#include <string>
using namespace std;

#include "AddressTests.h"
#include "../../../Domain/Addresses/Address/Address.h"

#include <cppunit/TestAssert.h>


void	AddressTests::setUp(){

	address_ =new Address;
	symbols_=new string("!@#$%^&*\\\"\(\(\',.?/;:}]{[|+=_-~`");
}

void	AddressTests::tearDown(){
	delete address_;
	address_ = NULL;
}

void	AddressTests::setTown_CharactersAsTownName_TownEqualToParameter(){

	string *town =  new string("serres");
	address_->setTown(town);
	bool result = ((*town)==(*address_->getTown()))?true:false;
	delete town;
	CPPUNIT_ASSERT_MESSAGE("Set town should set the town name as chars given name",true==result);
}

void	AddressTests::setTown_NumbersAsTownName_TownEqualToNull(){
	string *town =  new string("10105");
	address_->setTown(town);
	bool result = ((NULL)==(address_->getTown()))?true:false;
	delete town;
	CPPUNIT_ASSERT_MESSAGE("Town must be NULL if the setting parameter is number",(true==result));
}

void	AddressTests::setTown_SymbolsAsTownName_TownEqualToNull(){

	address_->setTown(symbols_);
	bool result = ((NULL)==address_->getTown())?true:false;
	CPPUNIT_ASSERT_MESSAGE("Town must be NULL if the setting parameter contains symbols",(true==result));
}
void	AddressTests::setTown_NumSymbCharAsTownName_TownEqualToNull(){
	string *town =  new string("!@#941Serres");
	address_->setTown(town);
	bool result = ((NULL)==(address_->getTown()))?true:false;
	delete town;
	CPPUNIT_ASSERT_MESSAGE("Town must be NULL if the setting parameter contain symbols,numbers and chars",(true==result));
}


void	AddressTests::setStreet_CharactersAsStreetName_StreetEqualToPamareter(){
	string	*street = new string("Merarxias");
	address_->setStreet(street);
	bool	result = ((*street)==(*address_->getStreet()))?true:false;
	delete street;
	CPPUNIT_ASSERT_MESSAGE("Set town should set the town name as the valid given name",(true==result));
}


void	AddressTests::setStreet_NumbersAsStreetName_StreetEqualToNull(){
	string	*street = new string("123456");
	address_->setStreet(street);
	bool	result = ((NULL)==(address_->getStreet()))?true:false;
	delete street;
	CPPUNIT_ASSERT_MESSAGE("Street should be NULL if the given street is number",(true==result));
}


void	AddressTests::setStreet_SymbolsAsStreetName_StreetEqualToNull(){
	address_->setStreet(symbols_);
	bool	result = ((NULL)==(address_->getStreet()))?true:false;
	CPPUNIT_ASSERT_MESSAGE("Street should be NULL if the given contains symbols",(true==result));
}

void	AddressTests::setStreet_NumSymbCharAsStreetName_StreetEqualToNull(){
	string	*street = new string("!@#$123Merarxias");
	address_->setStreet(street);
	bool	result = ((NULL)==(address_->getStreet()))?true:false;
	delete street;
	CPPUNIT_ASSERT_MESSAGE("Street should be NULL if the given contains symbols, numbers and chars",(true==result));
}

void	AddressTests::setStreet_NullAsStreetName_StreetEqualToNull(){
	address_->setStreet(NULL);
	bool	result = ((NULL)==(address_->getStreet()))?true:false;
	CPPUNIT_ASSERT_MESSAGE("Street should be NULL if the given is NULL",(true==result));
}

void	AddressTests::setNumber_CharactersAsStreetNumber_StreetNumberEqualToNull(){
	string *streetNumber = new string("MustBeNumber");
	address_->setNumber(streetNumber);
	bool result = ((NULL)==(address_->getNumber()))?true:false;
	delete streetNumber;
	CPPUNIT_ASSERT_MESSAGE("Street number must be null if the given parameter contains chars",(true==result));
}

void	AddressTests::setNumber_NumbersAsStreetNumber_StreetNumberEqualToParameter(){
	string *streetNumber = new string("1234");
	address_->setNumber(streetNumber);
	bool result = ((*streetNumber)==(*address_->getNumber()))?true:false;
	delete streetNumber;
	CPPUNIT_ASSERT_MESSAGE("Street number must be equal to parameter if is number",(true==result));
}

void	AddressTests::setNumber_SymbolsAsStreetNumber_StreetNumberEqualToNull(){
	address_->setNumber(NULL);
	bool result = ((NULL)==(address_->getNumber()))?true:false;
	CPPUNIT_ASSERT_MESSAGE("Street number must be null if the given parameter contains chars",(true==result));
}

void	AddressTests::setNumber_NumSymbCharAsStreetNumber_StreetNumberEqualToNull(){
	string *streetNumber = new string("!@#$Street1");
	address_->setNumber(streetNumber);
	bool result = ((NULL)==(address_->getNumber()))?true:false;
	delete streetNumber;
	CPPUNIT_ASSERT_MESSAGE("Street number must be null if the given parameter contains symbols ,chars and numbers",(true==result));
}

void	AddressTests::setNumber_NullAsStreetNumber_StreetNumberEqualToNull(){
	address_->setNumber(NULL);
	bool result = ((NULL)==(address_->getNumber()))?true:false;
	CPPUNIT_ASSERT_MESSAGE("Street number must be null if the given parameter contains chars",(true==result));
}
